package org.openmore.consumer.service.feign;

import io.swagger.annotations.ApiParam;
import org.openmore.consumer.dto.common.BaseResponse;
import org.openmore.consumer.service.feignImpl.DictionaryServiceImpl;
import org.openmore.consumer.dto.common.DictionaryDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;

@Service
@FeignClient(value = "openmore-opc", fallbackFactory = DictionaryServiceImpl.class)
public interface DictionaryService {

    /**查询菜单列表*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/dictionary/queryMenu")
    public BaseResponse selectMenuByPage(
            @RequestParam(required = false, defaultValue = "") @ApiParam(value = "菜单类型：first一级菜单，second二级菜单") String type,
            @RequestParam(required = false, defaultValue = "") @ApiParam(value = "菜单名") String name,
            @RequestParam(required = false, defaultValue = "1") @ApiParam(value = "分页第几页") Integer pageNum,
            @RequestParam(required = false, defaultValue = "50") @ApiParam(value = "每页多少记录") Integer pageSize);


    /**查询字典列表*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/dictionary/query")
    public BaseResponse selectAllByPage(
            @RequestParam(required = false, defaultValue = "") @ApiParam(value = "词典类型：public公共，private私有，all全部") String type,
            @RequestParam(required = false, defaultValue = "") @ApiParam(value = "词典名") String name,
            @RequestParam(required = false, defaultValue = "1") @ApiParam(value = "分页第几页") Integer pageNum,
            @RequestParam(required = false, defaultValue = "10") @ApiParam(value = "每页多少记录") Integer pageSize);


    /**查询字典树*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/dictionary/query/tree")
    public BaseResponse selectTreeByParentKey(
            @RequestParam(required = false, defaultValue = "") @ApiParam(value = "父词典key，为空返回所有") String parentKey);


    /**根据父ID查询字典*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/dictionary/query/page")
    public BaseResponse selectAllByParentKeyPage(
            @RequestParam(required = false, defaultValue = "") @ApiParam(value = "词典名") String parentKey,
            @RequestParam(required = false, defaultValue = "") @ApiParam(value = "type级别:一级,二级，表示下级") String typeLevel,
            @RequestParam(required = false, defaultValue = "") @ApiParam(value = "名称") String name,
            @RequestParam(required = false, defaultValue = "") @ApiParam(value = "排序") String sort,
            @RequestParam(required = false, defaultValue = "1") @ApiParam(value = "分页第几页") Integer pageNum,
            @RequestParam(required = false, defaultValue = "10") @ApiParam(value = "每页多少记录") Integer pageSize);


    /**根据ID查询字典数据*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/dictionary/{id}")
    public BaseResponse getDictionaryById(@PathVariable @ApiParam(required = true, value = "词典id") String id);


    /**更新字典信息*/
    @RequestMapping(method = RequestMethod.PUT, value = "/api/dictionary")
    public BaseResponse updateDictionary(@RequestBody @ApiParam(value = "新Dictionary信息", required = true) DictionaryDto dictionary);


    /**新建字典信息*/
    @RequestMapping(method = RequestMethod.POST, value = "/api/dictionary", consumes = {APPLICATION_JSON_UTF8_VALUE})
    public BaseResponse insertDictionary(@RequestBody @ApiParam(value = "创建Dictionary", required = true) DictionaryDto dictionary);


    /**删除字典信息*/
    @RequestMapping(method = RequestMethod.DELETE, value = "/api/dictionary/{id}")
    public BaseResponse deleteDictionary(@PathVariable @ApiParam(value = "id", required = true) String id);


    /**根据父key查询字典数据*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/dictionary/children/{parentKey}")
    public BaseResponse getChildrenByParentKey2(@PathVariable @ApiParam(value = "parentKey", required = true) String parentKey,
                                                @RequestParam(required = false, defaultValue = "false")  @ApiParam(value = "是否使用缓存", defaultValue = "false") Boolean cache);
}
